
// 748317
public class P37 {
	
	private static boolean isPrime(int n) {
		if (n == 1) {
			return false;
		}
		
		int max = (int) Math.sqrt(n);
		for (int i = 2; i <= max; i++) {
			if (n % i == 0) {
				return false;
			}
		}
		
		return true;
	}
	
	public static void main(String[] args) {
		int sum = 0;
		int count = 0;
		int i = 2;
		
		for (; true; i++) {			
			if (isPrime(i)) {
				//System.out.println("prime:" + i);
				int length = String.valueOf(i).length();
				
				if (length >= 2) {
					boolean allPrime = true;
					String num = String.valueOf(i);
					
					for (int j = 0; j < length - 1; j++) {
						
						if (!isPrime(Integer.parseInt(num.substring(j + 1)))) {
							allPrime = false;
							break;
						}
						
						if (!isPrime(Integer.parseInt(num.substring(0, num.length() - j - 1)))) {
							allPrime = false;
							break;
						}
					}
					
					if (allPrime) {
						System.out.println(i);
						count++;
						sum += i;
						
						if (count == 11) {
							break;
						}
						
					}
				}				
			}
		}
		System.out.println(sum);
	}
}
